﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dynamic.Facades.EntLib.Data;
using System.Data.SqlClient;
using System.Data;

namespace Dynamic.Testing.Web
{
    public partial class GetProductList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Database db = DatabaseFactory.CreateDatabase();
            SqlCommand sqlCom = new SqlCommand();
            sqlCom.CommandType = CommandType.Text;
            sqlCom.CommandText = "select * from dbo.product";

            DataSet dsCustom = db.ExecuteDataSet(sqlCom);
            string s = "";

            foreach (DataRow dr in dsCustom.Tables[0].Rows)
            {
                if (dr["cmmf"] == DBNull.Value || dr["ITEM NO"] == null)
                {
                    continue;
                }
                if (s.Length > 0)
                {
                    s += ",";
                }
                string cmmf = dr["cmmf"].ToString();
                string itemNo = dr["ITEM NO"].ToString();
                string ss = string.Format("\"{0}({1})\"", itemNo, cmmf);
                s += ss;

            }
            s = string.Format("[{0}]", s);
            Response.Write(s);
        }

        //   Database db = DatabaseFactory.CreateDatabase();
        //   SqlCommand sqlCom = new SqlCommand();
        //   sqlCom.CommandType = CommandType.Text;
        //   sqlCom.CommandText = "select * from dbo.product";

        //   DataSet dsCustom = db.ExecuteDataSet(sqlCom);
        //   string s = "";

        //   foreach (DataRow dr in dsCustom.Tables[0].Rows)
        //   {
        //       if (dr["cmmf"] == DBNull.Value || dr["ITEM NO"] == null)
        //       {
        //           continue;
        //       }

        //       string cmmf = dr["cmmf"].ToString();
        //       string itemNo = dr["ITEM NO"].ToString();
        //       string ss = string.Format("<option value='{1}'>{0}({1})</option>", itemNo, cmmf);
        //       s += ss;

        //   }
        //   s = "<option value='请选择...'>请选择..</option>"+s;
        //   Response.Write(s);
    }
}
